import java.util.Arrays;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class Text {
    public static void orderArray(int[] array){
        for (int i = 0; i < array.length; i++) {
            //array[i]=i;
            array[i]= array.length-1-i;
        }
    }
    public static void notOrderArray(int[] array){
        Random num =new Random();
        for (int i = 0; i < array.length; i++) {
            array[i]=num.nextInt(10_0000);
        }
    }

    public static void textSample(int[] array){
        System.out.println("排序前："+ Arrays.toString(array));
        Sort.countSort(array);
        System.out.println("排序后："+ Arrays.toString(array));
    }

    public static void textOther(int[] array){
        textInsert(array);
        textShell(array);
        textSelect(array);
        textHeap(array);
        textBullue(array);
        //textQuick(array);
        textMerge(array);
    }
    public static void main(String[] args) {
        int[] array =new int[20];
        //notOrderArray(array);
        orderArray(array);
        textSample(array);
        //textOther(array);
    }


    public static void textCount(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime =System.currentTimeMillis();
        Sort.countSort(array);
        long endTime =System.currentTimeMillis();
        System.out.println("计数排序耗时："+(endTime-startTime));
    }
    public static void textMerge(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime =System.currentTimeMillis();
        Sort.mergeSort(array);
        long endTime =System.currentTimeMillis();
        System.out.println("归并排序耗时："+(endTime-startTime));
    }
    public static void textQuick(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime =System.currentTimeMillis();
        Sort.quickSort(array);
        long endTime =System.currentTimeMillis();
        System.out.println("快速排序耗时："+(endTime-startTime));
    }

    public static void textBullue(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime =System.currentTimeMillis();
        Sort.bullueSort(array);
        long endTime =System.currentTimeMillis();
        System.out.println("冒泡排序耗时："+(endTime-startTime));
    }

    public static void textHeap(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime =System.currentTimeMillis();
        Sort.heapSort(array);
        long endTime =System.currentTimeMillis();
        System.out.println("堆排序耗时："+(endTime-startTime));
    }
    public static void textSelect(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime =System.currentTimeMillis();
        Sort.selectSort(array);
        long endTime =System.currentTimeMillis();
        System.out.println("选择排序耗时："+(endTime-startTime));
    }
    public static void textShell(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime =System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime =System.currentTimeMillis();
        System.out.println("希尔排序耗时："+(endTime-startTime));
    }

    public static void textInsert(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime =System.currentTimeMillis();
        Sort.insertSort(array);
        long endTime =System.currentTimeMillis();
        System.out.println("插入排序耗时："+(endTime-startTime));
    }





    public static void main1(String[] args) {
        int[]  array =new int[]{75,6,88,2,34,22};
        System.out.println("排序前："+ Arrays.toString(array));
        Sort.insertSort(array);
        System.out.println("排序后："+ Arrays.toString(array));
    }
}
